package com.ruifu.conversions.mq;

import com.alibaba.fastjson.JSON;
import com.ruifu.common.eneity.ConversionTaskQueue;
import com.ruifu.conversions.config.DirectConfig;
import com.ruifu.conversions.service.FileConversionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * @author lcq
 * @date 2019/9/19
 */
@Component
@Slf4j
public class TransformNotifyReceive {

    @Autowired
    private FileConversionService fileConversionService;
    @RabbitListener(queues = DirectConfig.QUEUE)
    public void receive(ConversionTaskQueue conversionTaskQueue) throws Exception {
        log.info("Mq队列开始消费：{}", JSON.toJSON(conversionTaskQueue));
        try {
            fileConversionService.conversionFileUpload(conversionTaskQueue);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("Mq队列消费异常：{}",JSON.toJSON(conversionTaskQueue));
        }
    }
}

